Completed
Pull Request — master (#92)
by
unknown
02:03
created

source.js ➔ ... ➔ before   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
c 1
b 1
f 0
nc 1
nop 1
dl 0
loc 11
rs 9.4285
1
var chai = require('chai');
2
var sinonChai = require('sinon-chai')
3
var expect = chai.expect
4
chai.use(sinonChai)
5
var sinon = require('sinon');
6
var path = require('path');
7
var fse = require('fs-extra');
8
9
var config = require('../../../src/cli').config
10
config.set({root: path.join(process.cwd(), 'test', 'fixtures')})
11
12
var cmsData = require('../../../src/cli').cmsData;
13
var Manager = require('../../../src/cli').Manager;
14
15
describe('Source', function() {
16
  before( function(done) {
17
    Manager.instance.init()
18
      .then(function () {
19
        this.fixture = {
20
          articleJsoninline: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-data-jsoninline.html'), 'utf8'),
21
          articleArrayinline: fse.readFileSync(path.join(process.cwd(), 'test', 'fixtures', 'templates', 'article-data-arrayinline.html'), 'utf8')
22
        }
23
        done()
24
        
25
      }.bind(this))
26
  });
27
28
  /**
29
   * 
30
   * 
31
   */
32
  it('cmsData.source.valueList', function(done) {
33
    var obj = {key:'titles'}
34
    var json = {abe_source:{}}
35
    cmsData.source.valueList(obj, this.fixture.articleJsoninline, json)
36
      .then(() => {
37
        chai.expect(json.abe_source.titles.length).to.be.equal(3);
38
        chai.expect(json.abe_source.titles[0].title).to.be.equal("rouge");
39
        
40
41
        obj = {key:'titles'}
42
        json = {abe_source:{}}
43
        cmsData.source.valueList(obj, this.fixture.articleArrayinline, json)
44
          .then(() => {
45
            chai.expect(json.abe_source.titles.length).to.be.equal(3);
46
            done()
47
          })
48
      })
49
  });
50
});
51